<?php
class TopNavMetaWidget  extends CWidget{
    
	//输出字符串
	private $out = '';
    
    private $controller= '';
    
	private $action= '';

	//关键字
	public $keywords = '';
	//描述
	public $description = '';


	public function init(){
        $this->controller = Yii::app()->controller->id;  
        $this->action = Yii::app()->controller->action->id; 
	}

	public function run(){
        $this->generateTopNavMeta();
		echo $this->out;
	}

    public function generateTopNavMeta(){
        $this->out = '';
        //关键字
        if(empty($this->keywords)){
        	$this->out .= <<<OUT
<!-- 关键字 -->
        <meta name="keywords" content="GoWhich,项目问题大集合,代码语言,Java,JavaScript,PHP,Python,Mysql,Sql,Object-C,C,C++,Cpp,IOS,CSS,Html,Nginx,NodeJs,MongoDB,Redis,Linux,Ubuntu,Memcached"/>\n
OUT;
        }else{
            $keywords = preg_replace('#(&nbsp\;)+#i', ' ', $this->keywords);
            $this->out .= <<<OUT
<!-- 关键字 -->
        <meta name="keywords" content="{$keywords}"/>\n
OUT;
        }

        //描述
        if(empty($this->description)){
            $this->out .= <<<OUT
        <!-- 描述 -->
        <meta name="description" content="GoWhich 即项目问题大集合,关于互联网开发、学习、记录实例展示的网站" />\n
OUT;
        }else{
            $content = preg_replace('#(&nbsp\;)+#i',' ',addslashes($this->description));
            $this->out .= <<<OUT
        <!-- 描述 -->
        <meta name="description" content="{$content}" />\n
OUT;
        }

        $this->out .= <<<OUT
        <!-- 分析统计 -->
        <meta name="google-translate-customization" content="ab1d78a45d40d60d-6105f0c13ad17d36-g7e2d028b4b2ec897-f" />
        <meta name="chinaz-site-verification" content="6eee6d5e-226d-485a-a134-6bde0390bbb9" />
        <!-- RSS -->
        <link title="RSS 2.0" type="application/rss+xml" href="http://feed.feedsky.com/GoWhich" rel="alternate" />\n
OUT;

    }
}


